<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<!DOCTYPE html>
<html>
<head>
</head>
<body>	
	<script type="text/javascript">
		var dataGrid;
		$(function() {
			dataGrid = $('#dataGrid').datagrid({
				url : '${pageContext.request.contextPath}/business/accounting/zdpzgl/dataGrid.shtml',
				
				fit : true,
				border : false,
				pagination : true,
				idField : 'id',
				pageSize : 20,
				pageList : [ 10, 20, 30, 40, 50 ],
				sortName : 'ID',
				sortOrder : 'ASC',
				checkOnSelect : false,
				selectOnCheck : false,
				nowrap : false,
				striped : true,
				rownumbers : true,
				singleSelect : true,
				columns : [ [{
					field : 'ID',
					title : '序号',
					width : 100,
					hidden : true
				},{
					field : 'YWLX',
					title : '业务类型',
					width : 100,
					sortable : true
				},{
					field : 'JFFSE',
					title : '借方发生额',
					width : 100,
					sortable : true
				}, {
					field : 'DFFSE',
					title : '贷方发生额',
					width : 100,
					sortable : true
				}, {
					field : 'FJDJS',
					title : '附件单据数',
					width : 100,
					sortable : true
				}, {
					field : 'JZRQ',
					title : '记账日期',
					width : 100,
					sortable : true
				}, {
					field : 'ZD',
					title : '制单',
					width : 100,
					sortable : true
				}
				, {
					field : 'FH',
					title : '复核',
					width : 100,
					sortable : true
				}
				, {
					field : 'JZ',
					title : '记账',
					width : 100,
					sortable : true
				}
				, {
					field : 'PZZT',
					title : '凭证状态',
					width : 100,
					sortable : true
				}
				, {
					field : 'HZPZH',
					title : '汇总凭证号',
					width : 100,
					sortable : true
				}, {
					field : 'PZZTBS',
					title : '凭证状态标识',
					width : 100,
					sortable : true
				}, {
					field : 'ZZBS',
					title : '制作标识',
					width : 100,
					sortable : true
				}, {
					field : 'PZLB',
					title : '凭证类别',
					width : 100,
					sortable : true
				}
				, {
					field : 'XSPZH',
					title : '显示凭证号',
					width : 100,
					sortable : true
				},
				{
					field : 'action',
					title : '操作',
					width : 100,
					formatter : function(value, row, index) {
						var str = '';
							str += $.formatString('<a onclick="chakan(\'{0}\',\'{1}\');" src="{2}" >查看</a>',row.XSPZH,row.JZRQ);
						return str;
					}
				}
				]],
				toolbar : '#toolbar',
				onLoadSuccess : function() {
					$('#zdpzglsearchForm table').show();
					parent.$.messager.progress('close');
					$(this).datagrid('tooltip');
				},
				onRowContextMenu : function(e, rowIndex, rowData) {
					e.preventDefault();
					$(this).datagrid('unselectAll');
					$(this).datagrid('selectRow', rowIndex);
					$('#menu').menu('show', {
						left : e.pageX,
						top : e.pageY
					});
				}
			});
			
			console.info(dataGrid);
			dataGrid.datagrid('resize');
		});
		
		$('#hsdw').combobox({
			url:'${pageContext.request.contextPath}/business/accounting/zdpzgl/hsdw.shtml',
		    valueField:'ID',
		    textField:'TITLE'
		});
		$('#cwzt').combobox({
			url:'${pageContext.request.contextPath}/business/accounting/zdpzgl/cwzt.shtml',
		    valueField:'ZTDM',
		    textField:'ZTMC'
		});
		function searchFun() {
			dataGrid.datagrid('load', $.serializeObject($('#zdpzglsearchForm')));
		}
		function cleanFun() {
			$('#zdpzglsearchForm input').val('');
			dataGrid.datagrid('load', {});
		}
		
		
		function xiugai() {
			var row = $('#dataGrid').datagrid('getSelections');
			id = row[0].ID;
			JZ = row[0].JZ;
			if(JZ!=null){
				$.messager.alert('通知',"此凭证信息不允许修改！");
			}else{
			parent.$.modalDialog({
				title : '修改',
				width : 780,
				height : 395,
				
				href : '${pageContext.request.contextPath}/business/accounting/zdpzgl/editPage.shtml?ID='+id,
				buttons : [ {
					text : '确认',
					handler : function() {
						parent.$.modalDialog.openner_dataGrid = dataGrid;//因为修改成功之后，需要刷新这个dataGrid，所以先预定义好
						var f = parent.$.modalDialog.handler.find('#form');
						f.submit();
					}
				} ]
			});
		}
		}
		
		function chakan(XSPZH,JZRQ){
				 $('#ck_ck_window').window({
					    title:'记账凭证',
					    width:1050,
					    height:500,
					    href : '${pageContext.request.contextPath}/business/accounting/zdpzgl/viewPage.shtml?XSPZH='+XSPZH+'&JZRQ='+JZRQ,
					    modal:true
					});
				 
			}
	</script>
	<div class="easyui-layout" data-options="fit : true,border : false">
		<div data-options="region:'north',title:'',border:false" style="height: 100px; overflow: hidden;" >
			<form id="zdpzglsearchForm">
				<table class="form_view_border" bordercolordark="#FFFFFF" bordercolorlight="#45b97c" border="px" cellpadding="0" cellspacing="0" style="">
					<tr>
					<th class="panel-header">核算单位</th>
							<td style="width: 160px">               
                                <input class="easyui-combobox" id="hsdw" name = "HSDW_EQ_STR" style="width: 190px;height: 27px;" data-options="valueField:'ID', textField:'TITLE', panelHeight:'auto'" >  
                            </td>
						<th class="panel-header">财务账套</th>
							<td style="width: 160px">               
                                <input class="easyui-combobox" id="cwzt" name = "ZTDM_EQ_STR" style="width: 190px;height: 27px;" data-options="valueField:'ZTDM', textField:'ZTMC', panelHeight:'auto'" >  
                            </td>
					</tr>
					<tr>
						<th class="panel-header">记账日期</th>
						<td><input  name="JZRQ_EQ_DATE_yyyyMMdd"
										class="form_view_input combo easyui-datebox"/></td>
						<th class="panel-header"><nobr>账户分类</nobr></th>
						<td><select name="FH" style="width: 190px;height: 27px;" class="easyui-combobox" 
						data-options="required: true, editable: false"> 
							<option value="0">所有</option> 
							<option value="1">未复核记账</option> 
							<option value="2">已复核记账</option> 
							</select></td>
					</tr>
				</table>
			</form>
		</div>
		<div data-options="region:'center',border:false">
			<table id="dataGrid"></table>
		</div>
	</div>
	<div id="toolbar" style="display: none;">
		    <a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'brick_add',plain:true" onclick="searchFun();">查询</a>
		    <a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'brick_delete',plain:true" onclick="cleanFun();">重置</a>
			<a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'brick_delete',plain:true" onclick="xiugai();">修改</a>
	</div>
<div id="ck_ck_window"></div>
</body>
</html>
